package com.onlyphoto.onlymall.mvp.view.activity

import androidx.recyclerview.widget.LinearLayoutManager
import com.onlyphoto.onlymall.R
import com.onlyphoto.onlymall.base.BaseActivity
import com.onlyphoto.onlymall.bean.response.ArticleBean
import com.onlyphoto.onlymall.mvp.contract.CQuestion
import com.onlyphoto.onlymall.mvp.presenter.PQuestionImpl
import com.onlyphoto.onlymall.mvp.view.binder.FaqBinder
import kotlinx.android.synthetic.main.activity_question.*

import me.drakeet.multitype.Items
import me.drakeet.multitype.MultiTypeAdapter


class QuestionActivity : BaseActivity<PQuestionImpl>(), CQuestion.IVQuestion {

    var layoutManager: LinearLayoutManager? = null
    var items: Items? = null
    var adapter: MultiTypeAdapter? = null

    override fun retry() {}

    override fun init() {
        initRv()
    }

    fun initRv(){
        layoutManager = LinearLayoutManager(this)
        items = Items()
        adapter = MultiTypeAdapter(items!!)
        adapter?.register(ArticleBean::class.java, FaqBinder())
        rv_faq.layoutManager = layoutManager
        rv_faq.adapter = adapter
    }

    override fun initListener() {
        back.setOnClickListener{
            finish()
        }
    }

    override fun loadData() {
        mPresenter?.getFaqList(1, 3)
    }

    override fun getFaqListSuccess(list: ArrayList<ArticleBean>) {
        items?.addAll(list)
        adapter?.notifyDataSetChanged()
    }

    override fun isFullScreen(): Boolean {
        //是否沉浸式， 默认非沉浸式
        return false
    }

    public override fun initCustomerStatusManager() {

    }

    override fun setContentViewId(): Int {
        return R.layout.activity_question
    }

    override fun createPresenter() {
        mPresenter = PQuestionImpl(mContext, this)
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

}
